//
//  JYCODController.m
//  JYFarm
//
//  Created by 花花 on 2017/10/16.
//  Copyright © 2017年 花花. All rights reserved.
//

#import "JYCODController.h"
#import "JYCODCell.h"
@interface JYCODController ()

@end
static NSString *const JYCODCellID = @"JYCODCellID";
static NSString *const TableViewCellID = @"TableViewCellID";
@implementation JYCODController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"货到付款";
    [self setupTableView];

}
- (void)setupTableView{
    
    [self.tableView registerNib:[UINib nibWithNibName:@"JYCODCell" bundle:nil] forCellReuseIdentifier:JYCODCellID];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:TableViewCellID];

    
        UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, kBtnHeight+30)];
        UIButton *rechargeBtn  =  [UIButton jy_buttontitle:@"确认付款" titleColor:kfColor frame:CGRectMake(10, 30, Screen_Width-20, kBtnHeight) target:self action:@selector(payOnClick) fontSize:17 bgImageName:@"login_button_background"];
    
        [footerView addSubview:rechargeBtn];
    
    self.tableView.tableFooterView = footerView;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if (section == 0) {
        return 1;
    }
    return 2;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableViewCellID];
        
        NSString *tip = @"合计金额: ";
        NSString *money = @"66.00元";
        NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc]initWithString:tip];
        
        NSDictionary *attributes =  @{
                                      NSFontAttributeName:kFont(13),
                                      NSForegroundColorAttributeName:[UIColor colorWithRed:0.94f green:0.13f blue:0.42f alpha:1.00f]
                                      };
        NSAttributedString *str = [[NSAttributedString alloc]initWithString:money attributes:attributes];
        [attributedStr appendAttributedString:str];
        cell.textLabel.font = kFont(13);
        cell.textLabel.attributedText = attributedStr;
        
        return cell;
    }else{
    
    JYCODCell *cell = [tableView dequeueReusableCellWithIdentifier:JYCODCellID];
    cell.orderNumberLabel.text = [NSString stringWithFormat:@"订单号%zd",arc4random_uniform(666888123)];
    cell.totalLabel.text = [NSString stringWithFormat:@"共%zd件商品",arc4random_uniform(100)];
    
    cell.collectionView.orderDataArr = @[@"全部",@"待付款",@"待发货",@"待收货",@"已完成",@"全部",@"待付款",@"待发货",@"待收货",@"已完成",@"全部",@"待付款",@"待发货",@"待收货",@"已完成"];
    return cell;
    
    }
    return nil;
}
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
//
////
////    if (section == 0) {
////        return 0;
////    }
////    return 10;
//}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 0) {
        
        return kTableView_rowHeight;
    }
    return 198;

}
- (void)payOnClick{

    NSLog(@"确认付款");
}
@end
